﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WinFormClient
{
    public partial class Form1 : Form
    {

        [StructLayout(LayoutKind.Sequential)]
         public struct MARGINS
         {
             public int Left;
             public int Right;
             public int Top;
             public int Bottom;
         }
 
        [DllImport("dwmapi.dll", PreserveSig = false)]
         static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
 
        [DllImport("dwmapi.dll", PreserveSig = false)]
         static extern bool DwmIsCompositionEnabled();
        
        protected override void OnLoad(EventArgs e)
         {
             if (DwmIsCompositionEnabled())
             {
                 MARGINS margins = new MARGINS();
                 margins.Right = margins.Left = margins.Top = margins.Bottom = this.Width+this.Height;
                 DwmExtendFrameIntoClientArea(this.Handle, ref margins);
             }
             base.OnLoad(e);
         }

        protected override void OnPaintBackground(PaintEventArgs e)
         {
             base.OnPaintBackground(e);
             if (DwmIsCompositionEnabled())
             {
                 e.Graphics.Clear(Color.Black);
             }
         }


        public Client client;
        public Form1(Client c)
        {
            InitializeComponent();
            this.client = c;
            //client.FinishedLoadGroup += new EventHandler(client_FinishedLoadContent);
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            client.Exit();
            Application.Exit();
        }


    }
}
